home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / batuti.arc / ANW.C next >
Text File  |  1990-01-11  |  2KB  |  79 lines

  1.  
  2. #include <dos.h>
  3. #include <mem.h>
  4. #include <alloc.h>
  5. #include <stdio.h>
  6. #include "anw.h"
  7.  
  8. /*
  9.  *
  10.  *       GetConnectionNumber --  get the current sation number you are logged
  11.  *       onto.
  12.  *
  13.  *        Richard Connelly,(C) 1989,1990
  14.  *
  15.  *       returns (int station)
  16.  *
  17.  */
  18.  
  19. int GetConnectionNumber(void)
  20. {
  21.    struct REGPACK r;
  22.  
  23.    r.r_ax=(0xdc00) ;           /* AH=DC get connection number */
  24.    intr(0x21,&r) ;           /* netware interrupt 21 */
  25.    return(r.r_ax & 0xff);          /* return the station number */
  26. }
  27.  
  28.  
  29. /*
  30.  *
  31.  *      GetConnectInfo  -- returns the connection information for
  32.  *      the station specified in the function.
  33.  *
  34.  */
  35.  
  36. CONNECTINFO GetConnectInfo(int station)
  37. {
  38.    struct REGPACK r ;
  39.    CONNECTINFO ci ;          /* structure for connect info */
  40.    OUTPACKET op ;
  41.  
  42.    memset(&ci,0,sizeof(ci));        /* clear the request buffer */
  43.    r.r_ds=_DS ;                /* set data seg s */
  44.    r.r_es=_DS ;
  45.    r.r_si=(int)&op ;                /* get ready for the call to */
  46.    r.r_di=(int)&ci;                 /* connection info 16h */
  47.    r.r_ax=0xe300 ;            /* get connection info */
  48.    ci.length=sizeof(ci) ;
  49.    op.length=sizeof(op) ;
  50.    op.function=0x0016 ;
  51.    op.station=station ;
  52.    intr(0x21,&r) ;                  /* call the ANW interrupt */
  53.    return(ci);
  54. }
  55.  
  56.  
  57. /*
  58.  *
  59.  *       GetStationAddress -- Get the NIC's address
  60.  *
  61.  */
  62.  
  63. char *GetStationAddress(void)
  64. {
  65.    struct REGPACK r;
  66.    char *nic;                        /* NIC's address */
  67.  
  68.    nic=(char *)malloc(4);
  69.    r.r_ax=0xee00;                    /* get station address function */
  70.    r.r_cx=0;                         /* initialize cx & bx */
  71.    r.r_bx=0;
  72.    intr(0x21,&r);                    /* ANW 2.1x function */
  73.    if ( r.r_ax==0xee00 && r.r_bx==0 && r.r_cx==0)
  74.       r.r_ax=0;
  75.    sprintf(nic,"%04x%04x%04x",r.r_cx,r.r_bx,r.r_ax);
  76.    return(nic);
  77. }
  78.  
  79.